// pages/catalog/catalog.js
var app = getApp();
var hostURL = app.globalData1.hostURL;
var ImageURL = app.globalData1.ImageURL

Page({
  data: {
    navLeftItems: [],//左侧
    navRightItems: [],//右侧
    curNav: 1,
    curIndex: 0,
    ImageURL: ImageURL
  },
  onLoad: function () {

    console.log(this.data.curNav+",,"+this.data.curIndex)
    var that = this

    wx.request({

      url: hostURL + 'sharedplatform-web/assortment/findAssortment.action',
      method: 'GET',
      data: {},
      header: {
        'Accept': 'application/json'
      },
      success: function (res) {
        console.log("请求成功")
        that.setData({
          navLeftItems: res.data.assortmentList,
          navRightItems: res.data.assortmentList
        })
      }
    })
  },

  //事件处理函数
  switchRightTab: function (e) {
    // 获取item项的id，和数组的下标值  
    let id = e.target.dataset.id,
      index = parseInt(e.target.dataset.index);
    // 把点击到的某一项，设为当前index  
    console.log(id+",,"+index)
    this.setData({
      curNav: id,
      curIndex: index
    })
  },

  tolist:function(e){
    var that=this
    var id = that.data.curNav
    console.log(",,"+id)
        wx.navigateTo({
     url: '../list/list?id='+id,
    })

  }

})